import * as React from "react";
import AdminLayout from "../../components/AdminLayout.tsx";
import TodayAttendance from "./TodayAttendance.tsx";
import AllAttendance from "./AllAttendance.tsx";
import UserSettings from "./UserSettings.tsx";

const UserMainWindow: React.FC = () => {
    const [isDrawerOpen, setIsDrawerOpen] = React.useState(true);
    const [selectedModule, setSelectedModule] = React.useState('todayAttendance');

    const handleDrawerToggle = () => {
        setIsDrawerOpen(!isDrawerOpen);
    };

    const handleModuleSelect = (moduleKey: string) => {
        setSelectedModule(moduleKey);
    };

    const modules = [
        {key: 'todayAttendance', label: '今日考勤情况'},
        {key: 'allAttendance', label: '所有考勤情况'},
        {key: 'userSettings', label: '修改个人信息'},
    ];

    return (
        <AdminLayout
            title="韵匙——个人用户管理后台"
            modules={modules}
            onModuleSelect={handleModuleSelect}
            isDrawerOpen={isDrawerOpen}
            onDrawerToggle={handleDrawerToggle}
            content={
                <>
                    {selectedModule === 'todayAttendance' && <TodayAttendance/>}
                    {selectedModule === 'allAttendance' && <AllAttendance/>}
                    {selectedModule === 'userSettings' && <UserSettings/>}
                </>
            }
        />
    );
};

export default UserMainWindow;
